var express = require('express');
var router = express.Router();

const user = require('../src/controller/user');
const testjson = require('../src/static/test.json');
const queryUrl = require('../src/mapper/queryPoi');

/* GET home page. */
router.get('/', function(req, res, next) {
    res.render('index', { title: 'Express' });
});

router.get('/login', function(req, res, next) {
    res.render('login', { "site": "Meishi", "name": "" })
})

router.post('/login', function(req, res, next) {
    user.login(req, res);
    console.log(user.login);
    // res.render('login',{"site":"Meishi"});
});

router.get('/recom', async(req, res, next) => {
    let jsonPois = await queryUrl.hotTop(10);
    res.render('recommend', { name: "dalo", jsonPois: jsonPois });
})

router.get('/poi', async(req, res, next) => {
    // let jsonPois = await queryUrl.hotTop(10);
    res.render('poi', { name: "dalo", jsonPois: 'jsonPois' });
})

module.exports = router;